package net.tv90.bfmccore.game.impl.cq;

import lk.vexview.gui.components.ButtonFunction;
import lk.vexview.gui.components.VexButton;
import lk.vexview.gui.components.VexComponents;
import lombok.Data;

import java.util.UUID;

@Data
public class ConquestAreaButton {
    private String url1;
    private String url2;
    private int imagePosX;
    private int imagePosY;
    private int imageX;
    private int imageY;
    private String index;
    private ButtonFunction function;
    private VexButton vexButton;

    public ConquestAreaButton(String url1, String url2, int imagePosX, int imagePosY, int imageX, int imageY, String index) {
        this.url1 = url1;
        this.url2 = url2;
        this.imagePosX = imagePosX;
        this.imagePosY = imagePosY;
        this.imageX = imageX;
        this.imageY = imageY;
        this.index = index;
    }

    public void addFunction(ButtonFunction buttonFunction) {
        function = buttonFunction;
    }

    public VexComponents getVexComponents(String redOrBlue, int windowWidth, int windowHeight) {
        VexButton button = new VexButton(UUID.randomUUID(), "", url1, url2,
                imagePosX * windowWidth / 854, imagePosY * windowHeight / 445,
                imageX * windowWidth / 854, imageY* windowHeight / 445);
        button.setFunction(function);
        button.setUrl("[local]BattleField/Menu_" + redOrBlue + "_" + index + ".png");
        button.setUrl2("[local]BattleField/Menu_" + redOrBlue + "_" + index + ".png");
        return button;
    }

    @Override
    public String toString() {
        return " BTN{" + vexButton.getId().toString() + " " + vexButton.getFunction() + "}\n";
    }
}
